package com.itheima.entity;

import com.alibaba.fastjson.JSON;
import com.itheima.vo.ConfigVO2;
import lombok.Data;

import java.util.List;

@Data
public class SysConfig {
    private Integer id;
    private String groupValue;
    private String tabValue;
    private String attrKey;
    private String attrName;
    private String attrValue;
    private Integer delFlag;
    private Integer type;
    private String configValue;
    private String validator;
    private String placeholder;
    private Integer canDelete;
    private Integer sortNum;
    
    public ConfigVO2 transformConfigVO2(){
        ConfigVO2 configVO2 = new ConfigVO2();
        configVO2.setId(this.id);
        configVO2.setGroup_value(this.groupValue);
        configVO2.setTab_value(this.tabValue);
        configVO2.setAttr_key(this.attrKey);
        configVO2.setAttr_name(this.attrName);
        configVO2.setAttr_value(this.attrValue);
        configVO2.setDel_flag(this.delFlag);
        configVO2.setType(this.type);
        List<String> configValueList = JSON.parseArray(this.configValue, String.class);
        configVO2.setConfig_value(configValueList);
        List<String> validatorList = JSON.parseArray(this.validator, String.class);
        configVO2.setValidator(validatorList);
        configVO2.setPlaceholder(this.placeholder);
        configVO2.setCan_delete(this.canDelete);
        configVO2.setSort_num(this.sortNum);
        return configVO2;
    }
}
